import Vue from 'vue'
import VueRouter from "vue-router";
import PageThree from "@/views/PageThree";
import Index from "@/views/Index";
import BookManage from "@/views/BookManage";
import AddBook from "@/views/AddBook";
import UpdateBook from "@/views/UpdateBook";

Vue.use(VueRouter)

// 路由配置
const routes = [
    {
        path: '/',
        name: '图书管理',
        component:Index,
        redirect:"/Books", // 默认显示page1
        // 子菜单
        children:[
            {
                path: '/Books',
                name: '所有书籍',
                show:true,
                component: BookManage
            },
            {
                path: '/addBook',
                name: '添加图书',
                show:true,
                component: AddBook
            },
            {
                path: '/updateBook',
                name: '修改图书',
                show:true,
                component:UpdateBook
            },
        ]

    },
    {
        path: '/',
        name: '导航二',
        component: Index,
        children: [{
            path: '/page3',
            name: '页面3',
            show:false,
            component: PageThree
        }]
    },

    //
    // {
    //     path: '/book',
    //     name: '导航三',
    //     component: Book
    // },

]

const router = new VueRouter(
    {
        mode: 'history',
        base: process.env.BASE_URL,
        routes
    })

// 导出变量 router，以便在别的地方导入
export default router

